module game {
    export class Processor_BRNN extends puremvc.SimpleCommand implements puremvc.ICommand {
        public constructor() {
            super();
        }
        public static NAME: string = "Processor_BRNN";
        private brnnProxy: BrnnProxy = null;
        /**
         * 注册消息
         */
        public register(): void {
            this.facade.registerCommand("Processor_BRNN", Processor_BRNN);
        }

        public execute(notification: puremvc.INotification): void {
            this.brnnProxy = BrnnProxy.getProxy();
            var Body: any = notification.getBody();//携带数据
            let msgdata = DataParser.WSReceiveMsg(RegDataBrnn, Body);
            if (Global.isEmpty(msgdata)) {
                return;
            }
            let mainCmd = msgdata["mainCmd"];
            let subCmd = msgdata["subCmd"];
            let data = msgdata["msgData"];
            if (InstructionsEnum.IS_TEST) {
                console.log("白人牛接收：", mainCmd, subCmd, msgdata)
            }
            if (Global.isEmpty(data)) {
                return;
            }
            switch (mainCmd) {
                case 1: {
                    if (subCmd == 100) {//登陆成功
                        this.brnnProxy.login(data);
                    }
                    if (subCmd == 101) {//正在其他游戏
                        Global.tipShow(data["szDescribeString"]);
                        SocketManager.closeSocket(InstructionsEnum.GAME_TYPE_NAME.BRNN);
                        InstructionsEnum.ID_GAME = "";
                    }
                    if (subCmd == 102) {//登陆完成
                        let obj2 = new Object();
                        obj2["wVisit"] = 0;
                        obj2["wVersion"] = 101122049;
                        obj2["wGameVersion"] = 101122049;
                        SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.BRNN, RegDataBrnn.CMD_GP_StartGame, obj2)
                    }
                    if (subCmd == 103) { //回到其他房间
                        SocketManager.closeSocket(InstructionsEnum.GAME_TYPE_NAME.BRNN);
                        game.AppFacade.instance.sendNotification(PanelNotify.HALL.HALL_RECONNECTGAME, data["wServerID"]);
                    }
                    break;
                }
                case 2: {
                    if (subCmd == 101) {//房间配置
                        this.brnnProxy.getRoomInfo(data);
                    };
                    break;
                }
                case 3: {
                    if (subCmd == 100) {//刷新广场人员信息
                        this.brnnProxy.userJoinSquare(data)
                    };
                    if (subCmd == 101) {//
                        this.brnnProxy.getUserInfo(data);
                    }
                    if (subCmd == 102) {//我分配到的座位
                        this.brnnProxy.userStateModify(data);
                    }
                    if (subCmd == 103) {//钱不够入座
                        SocketManager.closeSocket(InstructionsEnum.GAME_TYPE_NAME.BRNN)
                        Global.tipShow(data["szDescribeString"])
                    }
                    break;
                }
                case 4: {
                    if (subCmd == 100) {//请求坐下
                        let obj = {
                            wTableID: 65535,
                            wChairID: 65535,
                            szInsurePass: ""
                        }
                        SocketManager.sendMessage(InstructionsEnum.GAME_TYPE_NAME.BRNN, RegDataBrnn.CMD_GP_UserQuickSitdown, obj)
                    }
                    break;
                }
                case 100: {
                    if (subCmd == 100) {
                        //空闲
                        if (data["cbGameStatus"] == 0) {
                            RegDataBrnn.MainCMD_MsgId[100][101] = RegDataBrnn.gameFree
                        }
                        // 游戏中
                        if (data["cbGameStatus"] == 100 || data["cbGameStatus"] == 101) {
                            RegDataBrnn.MainCMD_MsgId[100][101] = RegDataBrnn.gamePlay
                        }
                    }
                    if (subCmd == 101) {//中途加入
                        this.brnnProxy.dataRecovery(data)
                    }
                    if (subCmd == 200) {//后端推送消息
                        if (data["wType"] == 515) {
                            Global.tipShow(data["szString"]);
                        } else {
                            EffectUtils.textFadeAway(data["szString"]);
                        }
                    }
                    if (subCmd == 300) {//牌局编号
                        this.brnnProxy.getSerialNumber(data);
                    }
                    break;
                }
                case 200: {
                    if (subCmd == 99) {//空闲等待
                        this.brnnProxy.waitNextGame(data)
                    }
                    if (subCmd == 100) {//游戏开始
                        this.brnnProxy.gameStart(data)
                    }
                    if (subCmd == 101) {//下注返回
                        this.brnnProxy.betReceive(data)
                    }
                    if (subCmd == 102) {//游戏结束
                        this.brnnProxy.gameOver(data)
                    }
                    if (subCmd == 106) {//中途加入推送路单
                        this.brnnProxy.receiveLuDan(data)
                    }
                    if (subCmd == 107) {//下注失败

                    }
                    if (subCmd == 200) {
                        this.brnnProxy.receiveUserList(data)
                    }
                    break;
                }
            }
        }
    }
}
